<?
// globals
require('globals.php');
$pageNavi = array(); 
$GET = array_to_object($_GET, false);
$GETs = array_to_object($_GET, true);
$POST = array_to_object($_POST, false);
$POSTs = array_to_object($_POST, true);

// functions

function array_to_object($array = array(), $slashes = false) {
	if (!empty($array)) {
		$data = false;
		foreach ($array as $akey => $aval) {
			$data -> {$akey} = $slashes ? addslashes($aval) : $aval;
		}
		return $data;
	}	
	return false;
}

function query($sql) {
	global $sqlDump;
	global $sqlConnection;
	$r = array();
	$q = pg_query($sqlConnection, $sql);
	if($q === false) {
		$error = pg_last_error();
		$sqlDump .= "$sql => $error\n\n";
		echo "ERROR SQL: $sql => $error\n\n";
		return $r;
	}
	$sqlDump .= "$sql\n\n";
	while($row = pg_fetch_object($q)) $r[] = $row;
	return $r;
}

function queryo($sql) {
	$r = query($sql);
	if(count($r) == 0) return false;
	return $r[0];
}

require('comments.php');
?>


